create database ThanhDN

go

use ThanhDN

go
select*from [User]
create table [User]
(
	[idUser] int identity(1,1) primary key,
	[username] varchar(50),
	[password] varchar(50),
	[address] varchar(100),
	[name] varchar(30),
	[phone] varchar(30),
	[email] varchar(100),
	[roleid] int
)

select*from [User] 
insert into [User] values('thanh','12345','hung yen','dqngoc','0972698515','hehe@gmail.com',1)

go
create table [Restaurant]
(
	[idRestaurant] int identity(1,1) primary key,
	[name] varchar(50),
	[phone] varchar(50),
	[address] varchar(100),
	[picture] varchar(256),
	[descr] varchar(200),
	[status] varchar(100)
)
go
create table [Tables]
(
	[idTables] int identity(1,1) primary key,
	[idRestaurant] int foreign key references Restaurant([idRestaurant]),
	[capacity] int ,
	[price] float,
	[picture] varchar(256),
	[descr] varchar(200),
	[status] varchar(100)
)
go
create table [Food] 
(
	[idFood] int identity(1,1) primary key,	
	[name] varchar(50),
	[price] float ,
	[persons] int,
	[vegetarian] varchar(100),
	[picture] varchar(256),
	[descr] varchar(500),
	[status] varchar(100)
)
go
create table [TableReservation]
 (
	[idTableReservation] int identity(1,1) primary key,	
	[usedate] varchar(30),
	[customer] varchar(50),
	[email] varchar(100),
	[phone] varchar(50),
	[descr] varchar(200),
	[idtable] int not null
)
go
create table [TableReservationDetail] 
(
	[idTableReservation] int foreign key references [TableReservation]([idTableReservation]),
	[idTables] int foreign key references [Tables]([idTables]),
)

go

create table [FoodOrder] 
(
	[idFoodOrder] int identity(1,1) primary key,
	[customer] varchar(50),
	[address] varchar(100),
	[phone] varchar(50),
	[orderdate] varchar(100),
	[descr] varchar(200),
	[vegetarian] varchar(20),
	[idFood] varchar(10)
)
go


create table [FoodOrderDetail]
 (
	[idFoodOrder] int foreign key references [FoodOrder]([idFoodOrder]),
	[idFood] int foreign key references [Food]([idFood]),
	[quantity] int,
	primary key([idFoodOrder],[idFood])
)

go